package com.ztsoft.user.controller.project;

import com.ztsoft.user.pojo.entity.project.DemandUnit;
import com.ztsoft.user.service.project.DemandUnitService;
import com.ztsoft.user.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@CrossOrigin("*")
@RestController
@RequestMapping("/demandUnit")
@Api(tags = "需求单位控制层")
public class DemandUnitController {

    @Resource
    private DemandUnitService demandUnitService;

    @PutMapping("/updateDemandUnit")
    @ApiOperation(value = "修改需求单位", notes = "修改需求单位")
    public Result<Object> updateDemandUnit(@RequestBody DemandUnit demandUnit) {
        return demandUnitService.updateDemandUnit(demandUnit);
    }

    @PostMapping("/addDemandUnit")
    @ApiOperation(value = "添加需求单位", notes = "添加需求单位")
    public Result<Object> addDemandUnit(@RequestBody DemandUnit demandUnit) {
        return demandUnitService.addDemandUnit(demandUnit);
    }

    @DeleteMapping("/deleteDemandUnit/{id}")
    @ApiOperation(value = "删除需求单位", notes = "删除需求单位")
    public Result<Object> deleteDemandUnit(@PathVariable("id") String id) {
        return demandUnitService.deleteDemandUnit(id);
    }

    @GetMapping("/getDemandUnitName")
    @ApiOperation(value = "查看所有需求单位", notes = "查看所有需求单位")
    public Result<Object> getDemandUnitName() {
        return demandUnitService.getDemandUnitName();
    }

}
